﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.OMM.HealthMonitor.Entity.Common;

namespace Sinacor.OMM.HealthMonitor.Entity.Router
{
    [Serializable()]
    public class MessageRouter : IHealthDataReset
    {

        HealthEntityBase _healthEntityBase;

        public MessageRouter()
        {
            _healthEntityBase = new HealthEntityBase();
        }

        public MessageRouter(HealthEntityBase healthEntityBase)
        {
            _healthEntityBase = healthEntityBase;
        }

        // Mensagens Roteadas por segundo
        private int _routedMessagesForSecond = -1;
        public int RoutedMessagesForSecond
        {
            get { return _routedMessagesForSecond; }
            set 
            { 
                _routedMessagesForSecond = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // (*1) Mensagens Roteadas para Fluxo Normal
        private long _defaultFlowRoutedMessagesQuantity = -1;
        public long DefaultFlowRoutedMessagesQuantity
        {
            get { return _defaultFlowRoutedMessagesQuantity; }
            set 
            { 
                _defaultFlowRoutedMessagesQuantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // (*2) Mensagens Otimizadas
        private long _optimizedRoutedMessagesQuantity = -1;
        public long OptimizedRoutedMessagesQuantity
        {
            get { return _optimizedRoutedMessagesQuantity; }
            set 
            { 
                _optimizedRoutedMessagesQuantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // (*3) Mensagens Roteadas para HFT
        private long _hftRoutedMessagesQuantity = -1;
        public long HftRoutedMessagesQuantity
        {
            get { return _hftRoutedMessagesQuantity; }
            set 
            { 
                _hftRoutedMessagesQuantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }


        // (*1) + (*2) + (*3) Total de Mensagens Roteadas
        private long _totalRoutedMessagesQuantity = -1;
        public long TotalRoutedMessagesQuantity
        {
            get { _totalRoutedMessagesQuantity = DefaultFlowRoutedMessagesQuantity + OptimizedRoutedMessagesQuantity + HftRoutedMessagesQuantity; return _totalRoutedMessagesQuantity; }
        }

        //Número de Ordens HFT em memória
        private int _memoryControlledOrdersQuantity = -1;
        public int MemoryControlledOrdersQuantity
        {
            get { return _memoryControlledOrdersQuantity; }
            set 
            { 
                _memoryControlledOrdersQuantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // Numero Mensagens em Fila Interna #2
        private long _internalQueuedMessages_02_Quantity = -1;
        public long InternalQueuedMessages_02_Quantity
        {
            get { return _internalQueuedMessages_02_Quantity; }
            set 
            { 
                _internalQueuedMessages_02_Quantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        // Limite Numero Mensagens em Fila Interna #2
        private long _limitInternalQueuedMessages_02_Quantity = -1;
        public long LimitInternalQueuedMessages_02_Quantity
        {
            get { return _limitInternalQueuedMessages_02_Quantity; }
            set 
            { 
                _limitInternalQueuedMessages_02_Quantity = value;
                _healthEntityBase.LastUpdate = DateTime.Now;
            }
        }

        #region IHealthDataReset Members
        public void Reset()
        {
            RoutedMessagesForSecond = 0;
            DefaultFlowRoutedMessagesQuantity = 0;
            OptimizedRoutedMessagesQuantity = 0;
            HftRoutedMessagesQuantity = 0;
            MemoryControlledOrdersQuantity = 0;
            InternalQueuedMessages_02_Quantity = 0;
        }

        #endregion
    }
}
